package middleware

import (
	"encoding/json"
	"fmt"
	ginfox "westarry/gin-fox/gin-fox"
)

type Rule struct{
	Id int 
	Name string
	Url string
	RequestMethod string
	NeedLogin uint
	NeedRight uint
}
func InitAuthPath(){
	fmt.Println("[ginfox]开始读取权限节点...")
	rules:=[]Rule{}
	ginfox.Gc.D.Table("gf_auth_rules").Find(&rules)
	fmt.Printf("权限节点:%v\n",rules)
	for _,r:=range rules{
		value,err:=json.Marshal(r)
		if err!=nil{
			fmt.Println("[ginfox]读取权限节点失败...")
		}
		ginfox.Gc.R.HSet("auth_rules",r.Url,string(value))
	}
	
}